<template>
  <div @click="uploadHead" class="main-head">
    <div class="sex"></div>
    <img class="head" width="102px" height="120px" :src="getHead"/>

    <!--操作-->
    <ROperator :operators="['setting']" @setting="changeSetting"/>
    <!--更改头像格式-->
    <div v-show="isChangeSetting" class="change-setting" @mouseleave="isChangeSetting=false">
<!--      <div class="choose-head-title">-->
<!--        <span>风格</span>-->
<!--        <div>-->
<!--          <span>隐藏</span>-->
<!--          &lt;!&ndash;按钮&ndash;&gt;-->
<!--        </div>-->
<!--      </div>-->
      <div class="choose-head">
<!--        <div @click.stop="chooseSetting(shape)"-->
<!--             :class="{'head-checked': shape === settings.shape}"-->
<!--             class="head-choice" v-for="(shape, index) in ['circle', 'rect', 'square', 'pentagon', 'hexagon']"-->
<!--             :key="index">-->
<!--        </div>-->
      </div>
    </div>
  </div>
</template>

<script>
import ROperator from '../base/ROperator'
import mixin from '../../store/mixin'

export default {
  name: 'Head',
  mixins: [mixin],
  data () {
    return {
      isChangeSetting: false
    }
  },
  props: ['compId'],
  components: {
    ROperator
  },
  methods: {
    uploadHead () {
      console.log('upload head')
    },
    changeSetting () {
      this.isChangeSetting = !this.isChangeSetting
    },
    chooseSetting (shape) {
      this.settings.shape = shape
      this.isChangeSetting = !this.isChangeSetting
    }
  },
  computed: {
    getHead () {
      let {img} = this.dataLs
      return img || require('@/assets/resume/user.svg')
    }
  }
}
</script>

<style scoped lang="less">
  .main-head {
    position: relative;
    cursor: pointer;
    width: 142px;
    padding-left: 20px;
    height: 140px;
    overflow: hidden;

    .change-setting {
      width: 183px;
      position: absolute;
      background: white;
      border: 1px solid whitesmoke;
      box-shadow: 2px 2px 1.2px whitesmoke;
      padding: 8px 5px;
      top: 20px;
      right: -20px;
      z-index: 2;

      .choose-head-title {
        display: flex;
        justify-content: space-between
      }

      .choose-head {
        width: 100%;
        padding-top: 20px;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-around;

        .head-choice {
          overflow: hidden;
          box-sizing: border-box;
          cursor: pointer;
          position: relative;
          width: 102px;
          height: 140px;
        }

        .head-checked {
          border: 1px solid lightskyblue;

          &:after {
            content: "";
            background: url("../../assets/resume/checked.svg");
            background-size: contain;
            width: 20px;
            height: 18px;
            position: absolute;
            right: 0;
            top: 0;
          }
        }
      }
    }

    .head {
      height: 100%;
      border-radius: 5px;
      overflow: hidden;
      transition: filter 0.1s linear;

      &:hover{
        filter: brightness(50%);
      }
    }
  }

</style>
